<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>CSS3写隔行换色</title>
		<style type="text/css">
			table,td{
				border: 1px solid red;
				border-collapse: collapse;
			}
			/*nth-child(n)
			 * n:从1开始,
			 */
			table>tbody>tr:nth-child(2n){
				background: paleturquoise;
			}
			table>tbody>tr:nth-child(3n){
				background: palevioletred;
			}
			table>tbody>tr:nth-child(2n-1){
				background: yellowgreen;
			}
		</style>
	</head>
	<body>
		<table>
			<thead>
				<tr>
					<th>用户名</th>
					<th>性别</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>哈哈</td>
					<td>男</td>
				</tr>
				<tr>
					<td>哈哈</td>
					<td>男</td>
				</tr>
				<tr>
					<td>哈哈</td>
					<td>男</td>
				</tr>
				<tr>
					<td>哈哈</td>
					<td>男</td>
				</tr>
				<tr>
					<td>哈哈</td>
					<td>男</td>
				</tr>
				<tr>
					<td>哈哈</td>
					<td>男</td>
				</tr>
				<tr>
					<td>哈哈</td>
					<td>男</td>
				</tr>
			</tbody>
			<!--<tfoot></tfoot>-->
		</table>
	</body>
</html>
